#ifndef B2D_STRINGUTILS_H
#define B2D_STRINGUTILS_H

#include "Prerequisites.h"
#include <sstream>

NS_B2D_BEGIN

class B2D_API StringUtils final
{
	B2D_STATIC_CLASS(StringUtils)

public:
	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// \brief	Parse a comma separated array of values.
	///
	/// \tparam	T		  	Type of the values.
	/// \param	str			  	The string to parse.
	/// \param	maxCount	  	Maximum number of values.
	/// \param [out]	values	The output values.
	///
	/// \return	The number of items parsed
	////////////////////////////////////////////////////////////////////////////////////////////////////
	template<typename T>
	static size_t GetCommaSeparated(const string& str, size_t maxCount, T* values)
	{
		std::stringstream ss(str);
		size_t count = 0;
		T value;
		while( ss >> value && count < maxCount)
		{
			values[count] = value;
			if (ss.peek() == ',')
				ss.ignore();
			++count;
		}
		return count;
	}
};

NS_B2D_END

#endif